Overview
There are two distinct ways in which control can be branched within a circuit:
- Distribution; and
- Competition.
We have already discussed branching by distribution, whereby every connected consumer receives a separate copy of a initial event. Competition is an alternative branching behavior where each connected consumer competes with every other connected consumer for a particular event.
How is Competition Provided by CLIP?
In most cases competition is the default behavior when connecting to an object. For example, when making multiple read connections to a transient store, each connector will compete for the next read event from that store:
However, in the case of connecting to a distributor, the default behavior cannot be competition because this would defeat the purpose of using a distributor. In this case it is necessary to explicitly specify competition and this is achieved using the competer object:
Consider the following example, in which a transient store 'ready-for-read' event is distributed to three methods:
If we want M1 to receive its own copy of the event but M2 and M3 to compete for another copy of the event then we use the competer object as follows: